import javax.imageio.ImageIO;
import mysql.JDBC;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.sql.*;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.Date;
import java.util.List;
import java.util.Timer;
import java.sql.Timestamp;

public class Library_ManagementJFrame extends JFrame {
    public static JTabbedPane tabbedPane;

    public static JTabbedPane getTabbedPane() {
        return tabbedPane;
    }
    GetIcon gi = new GetIcon();
    Lib_JPanel lib_jPanel = new Lib_JPanel( );
    private JPanel contentPanel;
    public Library_ManagementJFrame() {

        init_LMJFrame();
        addComponents();
    }
    private void init_LMJFrame() {
        this.setSize(800, 600);
        this.setTitle("图书管理系统 v1.0");
        this.setAlwaysOnTop(true);
        this.setLocationRelativeTo(null);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setLayout(new BorderLayout());
        this.setVisible(true);
    }
    private void addComponents() {
        tabbedPane = new JTabbedPane(JTabbedPane.LEFT);
        contentPanel = new JPanel();
        contentPanel.setLayout(new BorderLayout());

        tabbedPane.addTab("    主页   ",gi.getIcon("首页.png",30,30), lib_jPanel.createHomePanel());
        tabbedPane.addTab("图书管理", gi.getIcon("图书管理.png",30,30),lib_jPanel.createBookManagementPanel());
        tabbedPane.addTab("借阅图书", gi.getIcon("图书申请.png",30,30),lib_jPanel.createBorrowBookPanel());
        tabbedPane.addTab("归还图书", gi.getIcon("图书归还.png",30,30),lib_jPanel.createReturnBookPanel());
        tabbedPane.addTab("超时查询", gi.getIcon("已超时.png",30,30),lib_jPanel.createOverdueQueryPanel());
        tabbedPane.addTab("用户管理", gi.getIcon("用户管理.png",30,30),lib_jPanel.createUserManagementPanel());
        tabbedPane.addTab("系统管理",gi.getIcon("系统管理.png",30,30),lib_jPanel.createSystemManagementPanel());
        this.getContentPane().add(tabbedPane, BorderLayout.CENTER);
        tabbedPane.addChangeListener(e -> {
            int selectedIndex = tabbedPane.getSelectedIndex();
            lib_jPanel.showSelectedPanel(selectedIndex,contentPanel);
        });
    }

}

